package cn.shit;

import java.time.DayOfWeek;
import java.time.LocalDate;

public class TestDate {
    public static void main(String[] args) {
        // LocalDate 日期专用
        LocalDate date = LocalDate.ofEpochDay(1);
        int month = date.getMonthValue();
        int today = date.getDayOfMonth();
        int year = date.getYear();
        System.out.printf("%d, %d, %d \n", year, month, today);
        // 设置为这个月第一天.
        date = date.minusDays(today - 1);  // 减去天数
        DayOfWeek weekday = date.getDayOfWeek();
        int value = weekday.getValue();
        System.out.println("Mon Tue Wed Thu Fri Sat Sun") ;
        for (int i = 0; i < value; i++) {
            System.out.print("\t");
        }
        while(date.getMonthValue() == month) {
            System.out.print(date.getDayOfMonth());

            if (date.getDayOfMonth() == today) {
                System.out.print("*\t");
            } else {
                System.out.print("\t");
            }
            date = date.plusDays(1);
            if (date.getDayOfWeek().getValue() == 7) {
                System.out.println();
            }
        }
    }
}
